package com.zcn.io.web.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zcn.io.web.mapper.PayDetailMapper;
import com.zcn.io.common.entity.PayDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zcn.io.common.util.DateUtil;
import com.zcn.io.common.vo.PayDetailTotalVo;
import com.zcn.io.common.vo.PayDetailVo;

import java.math.BigDecimal;
import java.util.List;

/**
 * @desc:
 * @author: 202438 邱建伟
 * @date: 2024/9/22 16:03
 * @Copyright (c) 2024, 江苏金恒信息科技股份有限公司
 */
@Service
public class PayDetailService {
    @Autowired
    private PayDetailMapper payDetailMapper;


    public List<PayDetail> listAllByOrderId(String orderId) {
        LambdaQueryWrapper<PayDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select().eq(PayDetail::getOrderId,orderId).orderByDesc(PayDetail::getPayDateTime);
        return this.payDetailMapper.selectList(queryWrapper);
    }

    public void save(PayDetail payDetail) {
        String payDateTime = payDetail.getPayDateTime();
        if (StrUtil.isEmpty(payDateTime)) {
            payDetail.setPayDateTime(DateUtil.getDefaultDate());
        }

        this.payDetailMapper.insert(payDetail);
    }

    public void updateById(PayDetail payDetail) {
        this.payDetailMapper.updateById(payDetail);
    }

    public void deleteById(String id) {
        this.payDetailMapper.deleteById(id);
    }
}
